<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="photo" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{photoHome.managed ? 'Edit' : 'Add'} Photo</f:facet>



            <s:decorate id="addedField" template="layout/edit.xhtml">
                <ui:define name="label">Added</ui:define>
                <rich:calendar id="added"
                       required="true"
                          value="#{photoHome.instance.added}" datePattern="MM/dd/yyyy hh:mm a"/>
            </s:decorate>



            <s:decorate id="cameraBrandField" template="layout/edit.xhtml">
                <ui:define name="label">Camera brand</ui:define>
                <h:inputText id="cameraBrand"
                           size="64"
                      maxlength="64"
                          value="#{photoHome.instance.cameraBrand}">
                    <a:support event="onblur" reRender="cameraBrandField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="cameraModelField" template="layout/edit.xhtml">
                <ui:define name="label">Camera model</ui:define>
                <h:inputText id="cameraModel"
                           size="64"
                      maxlength="64"
                          value="#{photoHome.instance.cameraModel}">
                    <a:support event="onblur" reRender="cameraModelField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="dateTakenField" template="layout/edit.xhtml">
                <ui:define name="label">Date taken</ui:define>
                <rich:calendar id="dateTaken"
                          value="#{photoHome.instance.dateTaken}" datePattern="MM/dd/yyyy hh:mm a"/>
            </s:decorate>


            <s:decorate id="dscField" template="layout/edit.xhtml">
                <ui:define name="label">Dsc</ui:define>
                <h:inputTextarea id="dsc"
                               cols="80"
                               rows="10"
                              value="#{photoHome.instance.dsc}"/>
            </s:decorate>


            <s:decorate id="filesizeField" template="layout/edit.xhtml">
                <ui:define name="label">Filesize</ui:define>
                <h:inputText id="filesize"
                       required="true"
                          value="#{photoHome.instance.filesize}">
                    <a:support event="onblur" reRender="filesizeField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="linkField" template="layout/edit.xhtml">
                <ui:define name="label">Link</ui:define>
                <h:inputTextarea id="link"
                               cols="80"
                               rows="3"
                           required="true"
                              value="#{photoHome.instance.link}"/>
            </s:decorate>


            <s:decorate id="originalheightField" template="layout/edit.xhtml">
                <ui:define name="label">Originalheight</ui:define>
                <h:inputText id="originalheight"
                       required="true"
                          value="#{photoHome.instance.originalheight}">
                    <a:support event="onblur" reRender="originalheightField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="originalwidthField" template="layout/edit.xhtml">
                <ui:define name="label">Originalwidth</ui:define>
                <h:inputText id="originalwidth"
                       required="true"
                          value="#{photoHome.instance.originalwidth}">
                    <a:support event="onblur" reRender="originalwidthField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>





            <s:decorate id="titleField" template="layout/edit.xhtml">
                <ui:define name="label">Title</ui:define>
                <h:inputTextarea id="title"
                               cols="80"
                               rows="3"
                           required="true"
                              value="#{photoHome.instance.title}"/>
            </s:decorate>


            <s:decorate id="typeField" template="layout/edit.xhtml">
                <ui:define name="label">Type</ui:define>
                <h:inputText id="type"
                       required="true"
                           size="16"
                      maxlength="16"
                          value="#{photoHome.instance.type}">
                    <a:support event="onblur" reRender="typeField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="viewedField" template="layout/edit.xhtml">
                <ui:define name="label">Viewed</ui:define>
                <h:inputText id="viewed"
                       required="true"
                          value="#{photoHome.instance.viewed}">
                    <a:support event="onblur" reRender="viewedField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>

            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{photoHome.persist}"
                       disabled="#{!photoHome.wired}"
                       rendered="#{!photoHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{photoHome.update}"
                       rendered="#{photoHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{photoHome.remove}"
                      immediate="true"
                       rendered="#{photoHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancel"
             propagation="end"
                    view="/Photo.xhtml"
                rendered="#{photoHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty photoFrom ? 'PhotoList' : photoFrom}.xhtml"
                rendered="#{!photoHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="Album">
    <div class="association" id="albumParent">

        <h:outputText value="There is no album associated with this photo."
                   rendered="#{photoHome.instance.album == null}"/>

        <rich:dataTable var="_album"
                   value="#{photoHome.instance.album}"
                rendered="#{photoHome.instance.album != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="albumTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_album.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Access id</f:facet>
                <h:outputText value="#{_album.access.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Category id</f:facet>
                <h:outputText value="#{_album.category.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Created</f:facet>
                <h:outputText value="#{_album.created}">
                    <s:convertDateTime type="both" dateStyle="short"/>
                </h:outputText>
            </h:column>
            <h:column>
                <f:facet name="header">Description</f:facet>
                <h:outputText value="#{_album.description}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Lastupdated</f:facet>
                <h:outputText value="#{_album.lastupdated}">
                    <s:convertDateTime type="both" dateStyle="short"/>
                </h:outputText>
            </h:column>
            <h:column>
                <f:facet name="header">Owner id</f:facet>
                <h:outputText value="#{_album.owner.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Published</f:facet>
                <h:outputText value="#{_album.published}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Title</f:facet>
                <h:outputText value="#{_album.title}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button id="#{photoHome.instance.album != null ? 'changeParent' : 'selectParent'}" value="#{photoHome.instance.album != null ? 'Change' : 'Select'} album"
                       view="/AlbumList.xhtml">
                <f:param name="from" value="PhotoEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>

    <rich:tab label="Owner">
    <div class="association" id="ownerParent">

        <h:outputText value="There is no owner associated with this photo."
                   rendered="#{photoHome.instance.owner == null}"/>

        <rich:dataTable var="_user"
                   value="#{photoHome.instance.owner}"
                rendered="#{photoHome.instance.owner != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="ownerTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_user.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Dsc</f:facet>
                <h:outputText value="#{_user.dsc}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Email</f:facet>
                <h:outputText value="#{_user.email}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Firstname</f:facet>
                <h:outputText value="#{_user.firstname}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Lastloggedin</f:facet>
                <h:outputText value="#{_user.lastloggedin}">
                    <s:convertDateTime type="both" dateStyle="short"/>
                </h:outputText>
            </h:column>
            <h:column>
                <f:facet name="header">Lastname</f:facet>
                <h:outputText value="#{_user.lastname}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Password</f:facet>
                <h:outputText value="#{_user.password}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Registered</f:facet>
                <h:outputText value="#{_user.registered}">
                    <s:convertDateTime type="both" dateStyle="short"/>
                </h:outputText>
            </h:column>
            <h:column>
                <f:facet name="header">Role id</f:facet>
                <h:outputText value="#{_user.role.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Status id</f:facet>
                <h:outputText value="#{_user.status.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Username</f:facet>
                <h:outputText value="#{_user.username}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button id="#{photoHome.instance.owner != null ? 'changeParent' : 'selectParent'}" value="#{photoHome.instance.owner != null ? 'Change' : 'Select'} owner"
                       view="/UserList.xhtml">
                <f:param name="from" value="PhotoEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>

    <rich:tab label="Status">
    <div class="association" id="statusParent">

        <h:outputText value="There is no status associated with this photo."
                   rendered="#{photoHome.instance.status == null}"/>

        <rich:dataTable var="_status"
                   value="#{photoHome.instance.status}"
                rendered="#{photoHome.instance.status != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="statusTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_status.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Dsc</f:facet>
                <h:outputText value="#{_status.dsc}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Status</f:facet>
                <h:outputText value="#{_status.status}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button id="#{photoHome.instance.status != null ? 'changeParent' : 'selectParent'}" value="#{photoHome.instance.status != null ? 'Change' : 'Select'} status"
                       view="/StatusList.xhtml">
                <f:param name="from" value="PhotoEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
